﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Dtl;

namespace Dal
{
    public class DistributorsDao
    {
        public static List<Distributors> GetDistributors()
        {
            SqlDataReader rd;
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = new SqlConnection(Properties.Settings.Default.Defaultcnx);
            cmd.Connection.Open();
            cmd.CommandText = "Select * from bzorgunit";
            rd=cmd.ExecuteReader();

            List<Distributors> DistList = new List<Distributors>();
            
            while (rd.Read())
            {
 
                Distributors dst = new Distributors();
                dst.DistributorID=Convert.ToString(rd["idorgunit"]);
                dst.DistributorCD = Convert.ToString(rd["cdorgunit"]);
                dst.DistributorCountry = Convert.ToString(rd["cdlegalcode1"]);
                dst.DistributorName = Convert.ToString(rd["dsName"]);
                dst.DistributorStatus = Convert.ToString(rd["idstatus"]);
                DistList.Add(dst);
            }
            cmd.Connection.Close();
        return DistList;
        }

    }
}
